/**
 *     This file is part of cesm-ws.
 *
 *     cesm-ws, Web Service for Community Earth System Model
 *
 *     Copyright (c) 2010, Purdue University and/or affilicates or thrid-party contributors as
 *     indicated by the @author tags or express copyright attribution statements
 *     applied by the authors. All third-party contributions are distributed under
 *     license by Purdue University.
 *
 *     cesm-ws is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with this distribution.  If not, see <http://www.gnu.org/licenses/>.
 */

package edu.purdue.rcac.cesm.facade.bean;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import edu.purdue.rcac.cesm.persistence.model.CESMCaseConfig;
import edu.purdue.rcac.cesm.persistence.model.CESMCaseRuntime;
import edu.purdue.rcac.cesm.persistence.model.CESMCaseConfig.AccessLevel;
import edu.purdue.rcac.cesm.persistence.model.CESMCaseConfig.CaseStage;

@XmlRootElement(name = "case")
@XmlAccessorType(XmlAccessType.FIELD)
public class CaseInfo {
	// Case Config
	@XmlElement(name = "resolution", namespace = "")
	private String resolution;
	@XmlElement(name = "component-set", namespace = "")
	private String componentSet;
	@XmlElement(name = "access-level", namespace = "")
	private String accessLevel;
	@XmlElement(name = "resubmit", namespace = "")
	private int resubmit;
	@XmlElement(name = "name", namespace = "")
	private String name;
	@XmlElement(name = "stage", namespace = "")
	private String stage;
	@XmlElement(name = "start-date", namespace = "")
	private String startDate;
	@XmlElement(name = "end-date", namespace = "")
	private String endDate;
	@XmlElement(name = "duration", namespace = "")
	private String duration;
	@XmlElement(name = "creation-time", namespace = "")
	private String creationTime;
	@XmlElement(name = "machine", namespace = "")
	private String machine;

	// Case Runtime
	@XmlAttribute(name = "job-status", namespace = "")
	private String jobStatus;
	@XmlAttribute(name = "pbs-id", namespace = "")
	private String pbsid;
	@XmlAttribute(name = "start-time", namespace = "")
	private String startTime;
	@XmlAttribute(name = "used-wall-time", namespace = "")
	private String usedWallTime;
	@XmlAttribute(name = "used-cpu-time", namespace = "")
	private String usedCPUTime;
	@XmlAttribute(name = "queue", namespace = "")
	private String queue;

	public CaseInfo() {
		super();
		// Case Config Info
		this.name = "";
		this.accessLevel = AccessLevel.PUBLIC.toString();
		this.stage = CaseStage.NONE.toString();
		this.creationTime = "";
		this.resolution = "";
		this.componentSet = "";
		this.resubmit = 0;
		this.startDate = "0001-01-01";
		this.duration = "5:ndays";
		this.endDate = "0001-01-06";
		this.machine = "none";

		// Case Runtime Info
		this.jobStatus = "--";
		this.usedCPUTime = "--";
		this.usedWallTime = "--";
		this.startTime = "--";
		this.queue = "--";
		this.pbsid = "--";
	}

	public CaseInfo(CESMCaseConfig c, CESMCaseRuntime r) {
		this();
		if (c != null) {
			this.name = c.getName();
			this.accessLevel = c.getAccessLevel().toString();
			this.stage = c.getStage().toString();
			this.creationTime = c.getCreationTime().toString();

			this.resolution = c.getResolution().toString();
			this.componentSet = c.getComponentSet().toString();
			this.resubmit = c.getResubmit();

			this.startDate = c.getStartDate().toString();
			this.duration = c.getDuration();
			this.endDate = c.getEndDate();
			this.machine = c.getMachine().name();
		}
		if (r != null) {
			this.jobStatus = r.getJobStatus().toString();
			this.pbsid = r.getPbsid();
			this.startTime = r.getStartTime().toString();
			this.usedCPUTime = r.getUsedCPUTime();
			this.usedWallTime = r.getUsedWallTime();
			this.queue = r.getQueue();
		}
	}

	public String getJobStatus() {
		return jobStatus;
	}

	public void setJobStatus(String jobStatus) {
		this.jobStatus = jobStatus;
	}

	public String getPbsid() {
		return pbsid;
	}

	public void setPbsid(String pbsid) {
		this.pbsid = pbsid;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public String getUsedWallTime() {
		return usedWallTime;
	}

	public void setUsedWallTime(String usedWallTime) {
		this.usedWallTime = usedWallTime;
	}

	public String getUsedCPUTime() {
		return usedCPUTime;
	}

	public void setUsedCPUTime(String usedCPUTime) {
		this.usedCPUTime = usedCPUTime;
	}

	public String getQueue() {
		return queue;
	}

	public void setQueue(String queue) {
		this.queue = queue;
	}

	public String getResolution() {
		return resolution;
	}

	public void setResolution(String resolution) {
		this.resolution = resolution;
	}

	public String getComponentSet() {
		return componentSet;
	}

	public void setComponentSet(String componentSet) {
		this.componentSet = componentSet;
	}

	public String getAccessLevel() {
		return accessLevel;
	}

	public void setAccessLevel(String accessLevel) {
		this.accessLevel = accessLevel;
	}

	public int getResubmit() {
		return resubmit;
	}

	public void setResubmit(int resubmit) {
		this.resubmit = resubmit;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getStage() {
		return stage;
	}

	public void setStage(String stage) {
		this.stage = stage;
	}

	public String getStartDate() {
		return startDate;
	}

	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

	public String getDuration() {
		return duration;
	}

	public void setDuration(String duration) {
		this.duration = duration;
	}

	public String getCreationTime() {
		return creationTime;
	}

	public void setCreationTime(String creationTime) {
		this.creationTime = creationTime;
	}

	public String getMachine() {
		return machine;
	}

	public void setMachine(String machine) {
		this.machine = machine;
	}
}
